import { getAuthButtonListApi } from "@/api/modules/login";
import { useRoute } from "vue-router";

/**
 * @description 页面按钮权限
 * */
export const useAuthButtons = async (parentId?: string) => {
	const route = useRoute();
	if (parentId || (route && route.meta.id)) {
		const { result } = await getAuthButtonListApi({ parentId: parentId || (route.meta.id as string), type: "btn" });
		return result.records.children;
	} else {
		return [];
	}
};
/**
 * @description 页面所有按钮权限，包括按钮，操作，导入导出
 * */
export const useAuthButtonList = async (parentId?: string) => {
	const route = useRoute();
	if (parentId || (route && route.meta.id)) {
		const { result } = await getAuthButtonListApi({ parentId: parentId || (route.meta.id as string) });
		return result.records.children;
	} else {
		return [];
	}
};
